home *** CD-ROM | disk | FTP | other *** search
- if #argv==1
- eval time()
- return
- endif
- local t_FlLvl t_be4 t_after t_elapsed cmd
- set cmd "$*"
- onintr goto foo
- set t_FlLvl `failat`
- failat 2147483647 # Some programs return pointers as exit code.
- t_be4=rtime()
- $cmd
- label foo
- t_after=rtime(),t_elapsed=float(t_after-t_be4)/50.
- if t_elapsed < 0.0 # did we cross midnight ?
- t_elapsed += float (60*60*24)
- endif
- failat $t_FlLvl[2]
- echo >&2 time for $argv[1-*] = $t_elapsed seconds
- # time - use to determine the amount of time used by a program. The
- # resolution is .02 seconds. Time only determines the real time consumed;
- # this will generally be more than the cpu time used by a program.
- # The use of $* is not exactly elegant, as variable replacement is performed
- # after alias replacement thus precluding any alias substitution. Also,
- # the $* must be a simple command (no pipes...), or a script containing
- # more complex commands.
- #
- # Time is presented as is; no warrantee is either expressed or implied
- # as to it's suitability to any purpose whatsoever. You assume all the
- # risk for all damage, even if caused by a defect in the software,
- # no matter how awful.
-